function [votesm,missed,lopsided_votes]=clean_data(votes)
%This function removes legislators who vote on less than two thirds of the
%total votes and votes where the minority makes up less than 2.5% of the
%total votes cast.

%Legislators first
tmp=zeros(size(votes));
%Record missing votes as NaN
tmp(votes==7)=NaN;
tmp(votes==8)=NaN;
tmp(votes==9)=NaN;
tmp(votes==0)=NaN;
%Count the number of such votes
num_missed_votes=sum(isnan(tmp'));
%Record those who votes less than 2/3 of the time
missed=find(num_missed_votes/size(votes,2)>1/3);

votesm=votes;
%Delete those members
votesm(missed,:)=[];

%Votes second
lopsided_votes=[];

%For each vote, find all the yeas and nays
for i=1:size(votesm,2)
    yeas=find(votesm(:,i)==1);

    nays=find(votesm(:,i)==-1);
    %If the minority percent is too low, record the vote as a lopsided vote
    if or(numel(nays)/(numel(nays)+numel(yeas))<0.025,numel(yeas)/(numel(nays)+numel(yeas))<0.025)
        lopsided_votes=[lopsided_votes,i];
    end
end
    %Delete those votes

    votesm(:,lopsided_votes)=[];
    %Make the voting codes uniform
    votesm(votesm==2)=1;
    votesm(votesm==3)=1;
    votesm(votesm==4)=6;
    votesm(votesm==5)=6;
    votesm(votesm==7)=9;
    votesm(votesm==8)=9;
    
    
    
    






